/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.thelostlands.plugins.TheLostKindness;

import org.bukkit.entity.Player;

/**
 *
 * @author fabio
 */
public class KindPlayer {


    Player p;
    public boolean given;
   // public int taken;
    public int points;
    private static KindPlayer first, second, third;

    public boolean hasAPoint() {
        return !given;
    }

    public void giveAPointTo(KindPlayer get) {
        if(!given){
            get.points++;
            get.updatePosition();
            given=true;
        }
        else
        {//non c'è niente da fare, qui non so chi è il sender
        }
    }
    
    public String getPoints()
    {
        return "Hai ottenuto " + points + " punti!";
    }

    public static String getHits(int position) {
        switch (position)
        {
            case 0:
                if(first==null) return "Nessuno ha ancora un punto";
                return first.toString();
            case 1:
                if(second==null) return "Non esiste ancora un secondo";
                return second.toString();
            case 2:
                if(third==null) return "Non esiste ancora un terzo";
                return third.toString();
            default:
                return "posizione non valida";
        }
    }

    private void updatePosition() {
        if(first==null){
            first=this;
            return;
        }
        if(second==null){
            second=this;
            return;
        }
        if(third==null){
            third=this;
            return;
        }
        if(third.points>=points)return;
        if(second.points>points){
            third=this;
            return;
        }
        third=second;
        if(first.points>points){
            second=this;
            return;
        }
        second=first;
        first=this;       
    }
}
